<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>登陆</title>
		<link rel="stylesheet" href="/layui/css/layui.css">
		<link rel="stylesheet" href="/layui/css/style.css">
	</head>
	<body>
		<div class="login-main">
    <header class="layui-elip">后台登录</header>
    <form class="layui-form">
        <div class="layui-input-inline">
            <input type="text" name="account" required  lay-verify="required" placeholder="邮箱" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password" required  lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline login-btn">
            <button type="submit" lay-submit lay-filter="sub" class="layui-btn">登录</button>
        </div>
    </form>
</div>
<script src="/assets/js/building/jquery-1.11.1.min.js"></script>
<script src="/layui/lay/dest/layui.all.js"></script>
<script src='/assets/js/codeigniter-csrf.js'></script>
<script type="text/javascript">
    layui.use(['form'], function () {
        var form = layui.form();
        form.on('submit(sub)', function(data){
            if (data.field.account == "") {
                alert('账号不能为空');
                return false;
            }
            if (data.field.password == "") {
                alert('密码不能为空');
                return false;
            }
            var URL="/report/login";
            $.ajax({
                type: "POST",
                url: URL,
                dataType:'json',
                data: {
                    'account':data.field.account,
                    'password':data.field.password,
                    'ci_csrf_token': ci_csrf_token()
                },
                success: function(data){
                    if(data.status == 1){
                        layer.msg(data.errMsg, {
                            time: 1000, //1s后自动关闭
                        });
                        window.location.href = "/report/data";
                    }else{
                        layer.msg(data.errMsg, {
                            time: 1000, //20s后自动关闭
                        });
                    }
                }
            });
            return false;
        });
    });
</script>
	</body>
</html>
